import request from '@/utils/request'

export function getRuleList(params?: RuleParamsType) {
  return request<RuleType[]>({
    url: '/setting/menus',
    method: 'get',
    params,
  })
}

export function setRuleStatus(id: number, data: { is_show: number }) {
  return request({
    url: `/setting/menus/show/${id}`,
    method: 'put',
    data,
  })
}

export function getRuleInfo(id: number) {
  return request<RuleType>({
    url: `/setting/menus/${id}`,
    method: 'get',
  })
}

export function submitRule(data: RuleType, id: number | null) {
  return request({
    url: id ? `/setting/menus/${id}` : '/setting/menus',
    method: id ? 'put' : 'post',
    data,
  })
}

// export function submitRule(data: RuleType) {
//   return request({
//     url: '/setting/menus',
//     method: 'post',
//     data,
//   })
// }

export function deleteRule(id: number) {
  return request({
    url: `/setting/menus/${id}`,
    method: 'delete',
  })
}
